using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Content_Extension
{
    public class ZipFile
    {
        Ionic.Zip.ZipFile file = new Ionic.Zip.ZipFile();

        public ZipFile(string FileName)
        {
            file = new Ionic.Zip.ZipFile(FileName);
        }

        /// <summary>
        /// Returns a stream to the entry if the entry exists
        /// </summary>
        /// <param name="filename">The filepath in the zip to the file</param>
        /// <returns></returns>
        public System.IO.StreamReader GetFile(string filename)
        {
            Ionic.Zip.ZipEntry entry = file[filename];
            System.IO.Stream temp = System.IO.Stream.Null;

            if (entry != null)
            {
                entry.Extract(temp);
                return new System.IO.StreamReader(temp);
            }

            return null;
        }
    }
}
